home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / bin / callback < prev    next >
Text File  |  1994-03-10  |  3KB  |  116 lines

  1. #!/bin/sh
  2. # @(#) callback - JPRadley v1.0 920921 - makes and uses an 'xc' script to
  3. # @(#)   call a remote site, have it ring us back with a login prompt.
  4.  
  5. echo -n "Remote system name? "
  6. read SYSTEM                     # where are we calling?
  7. echo -n "Their modem number? "
  8. read NUMBER                     # what's the telephone number?
  9. echo -n "Login name on $SYSTEM? "
  10. read LOGIN                      # how shall we log in?
  11. echo -n "Password for $LOGIN? "
  12. stty -echo                      # but of course!
  13. read PASSWD
  14. stty echo
  15. echo -n "\nBaud remote should use? "
  16. read RSPEED                     # computer-modem speed on the remote
  17. echo
  18.  
  19. What_To_Do=/usr/tmp/$SYSTEM.$$  # script for 'xc' to use
  20. OURPORT=ttyA02                  # we'll dial out on this port and the remote
  21. OURNBR=7874639                  #  calls this number to ring this port
  22. CAPTURE=/pub/jpr/logs/$SYSTEM   # our log file for the session
  23.  
  24. trap "rm $What_To_Do" 0         # clean up when we leave
  25.  
  26. cat >$What_To_Do <<TeMpLaTe
  27. debug "off"
  28. tty "off"
  29. set cfile $CAPTURE                
  30. set auto "off"                  # no capturing -- yet
  31. set cis "off"                   # don't react to a spurious ^E
  32.  
  33. transmit "ats0=0e1q0v1^M"       # modem should not be mute
  34. waitfor "ok"
  35.  
  36. dial "$NUMBER"
  37. echo "        Dialing $NUMBER to get on to $SYSTEM"
  38. while ! waitfor "connect" 70
  39. do
  40.         echo "        No connection; redialing"
  41.         redial                        
  42. done
  43.  
  44. transmit "^M"                   # can't hurt
  45.  
  46. assign PATIENCE eq 3            # loop counter
  47. while ! waitfor "ogin:" 6       # waiting 6 secs for the prompt
  48. do
  49.         if PATIENCE eq 0
  50.         then    echo "Can't get a login prompt"
  51.                 beep; quit
  52.         fi
  53.         xmitbrk
  54.         decr PATIENCE
  55. done
  56.  
  57. pause 2
  58.  
  59. transmit "$LOGIN^M"
  60. echo "        We're logging in now"
  61.  
  62. if ! waitfor "word:"
  63. then
  64.         echo "Login failed, sorry!" ; beep; quit
  65. else
  66.         transmit "$PASSWD^M^M"  # the second CR is to cope with a possible
  67. endif                           #  tset command, and accept its default
  68.  
  69. transmit "/1/2/3^M"             # an absolute pathname that shouldn't exist
  70. if waitfor "not found"
  71. then
  72.         echo "        OK, we're on $SYSTEM; now we'll set up a callback"
  73. else
  74.         echo "Login failed, sorry!" ; beep; quit
  75. fi
  76.  
  77. transmit "echo 'yes|ct -w3 -s$RSPEED $OURNBR 2>/dev/null' | at now next min^M"
  78. waitfor "job"                   # the 'at' command reports a job number
  79. transmit "exit^M"               # get off the remote system
  80.  
  81. pause 2                         # disconnect might reset modem, so again:
  82. transmit "ats0=1e1q0v1^M"       #  not mute, and auto-answer
  83. waitfor "ok"
  84.  
  85. echo "        It might be a couple of minutes until $SYSTEM rings us"
  86. if ! waitfor "connect" 190
  87. then
  88.         echo "        It ain't gonna happen; sorry!"
  89.         beep; quit
  90. endif
  91.  
  92. transmit "^M"
  93. assign PATIENCE eq 3
  94. while ! waitfor "ogin:" 6
  95. do
  96.         if PATIENCE eq 0; then beep; quit; fi
  97.         xmitbrk; decr PATIENCE
  98. done
  99. pause 1; transmit "$LOGIN^M"
  100. if ! waitfor "word:"; then beep; quit
  101. else transmit "$PASSWD^M^M"
  102. fi
  103.  
  104. set auto "on"                   # capturing starts when we hit terminal mode
  105.  
  106. transmit "/1/2/3; echo Thanks, \`uname\`, for providing this connection!^M"
  107. waitfor "not found"
  108. beep
  109. TeMpLaTe
  110.  
  111. xc -s$What_To_Do -l$OURPORT
  112.  
  113. # th-th-aaa-t's all, folks, just drop those nickels & dimes in the slot...
  114.  
  115. # eof(callback)
  116.